package com.market.category.dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import com.market.category.domain.CategoryCommand;

@Component
public class CategoryDaoImpl extends SqlSessionDaoSupport implements CategoryDao{
	@Override
	public void insert(CategoryCommand category) {
		getSqlSession().insert("insertCategory", category);
	}
	
	@Override
	public void delete(int c_code) {
		getSqlSession().delete("deleteCategory", c_code);		
	}
	
	@Override
	public void update(CategoryCommand category) {
		getSqlSession().update("updateCategory", category);
	}
	
	@Override
	public int getRowCount(Map<String, Object> map) {
		return getSqlSession().selectOne("Category.selectCount", map);
	}
	
	@Override
	public List<CategoryCommand> list(Map<String, Object> map) {
		List<CategoryCommand> list = getSqlSession().selectList("Category.selectList", map);
		return list;
	}	
	@Override
	public CategoryCommand select(int c_code) {
		CategoryCommand category = (CategoryCommand)getSqlSession().selectOne("Category.select", c_code);
		return category;
	}
	
	@Override
	public List<CategoryCommand> selectedMarket(int c_code) {
		List<CategoryCommand> list = getSqlSession().selectList("selectedMarket", c_code);
		return list;
	}
	
	@Override
	public List<CategoryCommand> selectedCategory(int c_code) {
		List<CategoryCommand> list = getSqlSession().selectList("selectedCategory", c_code);
		return list;
	}
}
